package com.siyu.basedata.modelparam.controller;

import com.siyu.basedata.modelparam.domain.ModelParam;
import com.siyu.basedata.modelparam.service.IModelParamService;
import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * xaj模型参数Controller
 *
 * @author hrhy
 * @date 2024-06-15
 */
@RestController
@RequestMapping("/predict/modelparam")
public class ModelParamController extends BaseController
{
    @Autowired
    private IModelParamService modelParamService;

    /**
     * 查询xaj模型参数列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ModelParam modelParam)
    {
        startPage();
        List<ModelParam> list = modelParamService.selectModelParamList(modelParam);
        return getDataTable(list);
    }

    /**
     * 导出xaj模型参数列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelParam modelParam)
    {
        List<ModelParam> list = modelParamService.selectModelParamList(modelParam);
        ExcelUtil<ModelParam> util = new ExcelUtil<ModelParam>(ModelParam.class);
        util.exportExcel(response, list, "xaj模型参数数据");
    }

    /**
     * 获取xaj模型参数详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(modelParamService.selectModelParamById(id));
    }

    /**
     * 新增xaj模型参数
     */
    @PostMapping
    public AjaxResult add(@RequestBody ModelParam modelParam)
    {
        return toAjax(modelParamService.insertModelParam(modelParam));
    }

    /**
     * 修改xaj模型参数
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ModelParam modelParam)
    {
        return toAjax(modelParamService.updateModelParam(modelParam));
    }

    /**
     * 删除xaj模型参数
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(modelParamService.deleteModelParamByIds(ids));
    }
}
